home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
windows
/
lfnsrt14.zip
/
LFNSORT.TXT
< prev
Wrap
Text File
|
1996-09-15
|
22KB
|
485 lines
LFNSORT v 1.4 - Sorts DOS/Win95 directories
Copyright (c) 1995,1996 D.J. Murdoch.
0. Contents of this file
1. Syntax
2. Description
3. Details
4. Memory Limitations
5. Safety
6. License
7. Release History
8. Known bugs
9. Acknowledgments
1. Syntax:
LFNSORT sortkeys [dirname] [options]
will sort the directory records on disk according to the
specified sort keys.
Keys:
N - full filename
E - extension
D - last modification date
T - last modification time
C - creation date/time
A - last access date/time
S - size
Place a "-" minus sign in front of a key to sort in descending
order instead of ascending order. Keys can be combined, e.g.
"-DN" for "sorted by descending modification date, and by
ascending name within date". Use "-" by itself as a placeholder
if you want no sort key.
Options:
/8 base sort order on 8.3 version of names instead of long
names
/C case sensitive sort - ascii sort order
/D mix directories in with files
/Debug file write debug information to file
/F filename read forced sort order from file (see below for
syntax and examples
/K keep erased entries, and keep directory at original
size, even if not all space is used
/NW no write - changes won't be saved to disk
/S sort subdirectories recursively
/System don't sort system files first in the root dir
/V verbose mode; list all directories and filenames after
sorting
Examples:
To sort every subdirectory on drive C: by file extension then
filename:
LFNSORT en c:\ /s
To sort every directory on drive C: so that most recently
accessed files come first:
LFNSORT -a-d-t c:\ /s
(The "-d-t" is necessary because not all directory records
include an access time; older ones and ones created in DOS mode
will only have a modification time.)
2. Description:
The original Norton Utilities had a program called DS which
could sort your DOS directories according to your preferences.
Later versions added a graphical interface so you could manually
move files around.
When Win95 came out with the VFAT long filenames, DS stopped
working. It hadn't been written to handle the new directory
records. Symantec (the current owners of the Norton Utilities)
haven't produced a new version of DS as far as I know, so when
Jacques Bensimon suggested that a minor modification to my
long filename backup utility DOSLFNBK could do directory sorts,
I decided that I wanted DS badly enough to write it myself.
There is already at least one freeware/shareware utility called
DIRSORT, so I called mine LFNSORT.
3. Details:
Disk locking:
LFNSORT works on the disk drive at a pretty low level. To be
allowed this access, it requests exclusive access to the drive
from Windows. If another program has already requested
exclusive access, LFNSORT will exit and do nothing. While
LFNSORT is running, other programs will not be allowed to write
to the disk or to create new files. This may confuse them; it's
probably best not to attempt any other disk activity in the
middle of an LFNSORT run. (LFNSORT has been written according to
Microsoft's instructions to work without damaging your disk even
if another program attempts access, but the other program might
not be.)
LFNSORT handles the disk locking itself. In fact, if you use
the LOCK command to lock the drive, LFNSORT will be unable to
obtain a lock, and will not run.
If you run LFNSORT under DOS, or in a version of Windows that
doesn't support drive locking, it will still run. If it detects
Windows it will warn you that running in a multitasker without
protecting the disk from changes is dangerous, and will only
go ahead if you confirm you really mean it. If it doesn't detect
Windows, it will assume that it is safe to go ahead --- so if
you're using another multitasker like Desqview, use it with
extreme care!
Forcing a particular order:
The /F option takes a plain ascii file as an argument. This
file should have the following format:
\directory1
firstfile
secondfile
thirdfile
\directory2
afile
bfile
cfile
Specifically: any line with a backslash "\" in it is taken as a
directory name, any other non-blank line is taken as a filename.
These will force the files in directory1 and directory2 into the
order given. If a file isn't listed, it will normally appear
*after* all the listed files. However, you can override this by
putting a "*" entry in place of a file; then all unlisted files
will be placed there. For example,
\directory
firstfile
*
lastfile
will guarantee the placement of those two files, but sort
everything else according to the specified sort keys. (Hint:
if you want to use the file to specify part of the order but
make no other changes, use "-" as a sort key.)
The order in which the directory sections appear in this file is
ignored. If you want directories in a particular order, list
them in a section for their parent directory. If you don't
specify any directory name, the ordering is used as a default
for unlisted directories. For example, to put README.1ST
files first in every directory where they exist, put a single
line containing "README.1ST" into a file called FORCED.LST, and
run
LFNSORT - c:\ /f forced.lst
File and directory names in this file may normally be either 8.3
aliases or long filenames, but if you're running outside Windows
where there is no long filename support, you *must* use the 8.3
alias.
If you want to force the file order for a large collection of
directories, you can use the /V option to create a preliminary
version of the forcing file. For example,
LFNSORT - c:\ /D/System/NW/S/V >new.lst
will write a list of the files in their current order
into the "new.lst" file. The - specifies no sorting, and the
/D and /System options turn off the default actions for
directories and system files.
Moving system files:
Normally the root directory of your boot drive has IO.SYS first,
and MSDOS.SYS in the second place. As long as these are left
with the System and Hidden attributes set, LFNSORT won't move
them. However, if you accidentally move them and want to
restore them to the start of the directory (because some
versions of DOS won't boot if they get moved):
Put these two lines in a file called FORCED.LST:
IO.SYS
MSDOS.SYS
and run
LFNSORT - c:\ /F forced.lst /System /D
Volume labels:
Pre-7.0 versions of DOS can be confused by long filename
records, which look to them like volume labels. This can be
fixed by putting the volume label before any long filenames in
the directory, but the Win95 LABEL command doesn't do this.
LFNSORT fixes this, unless you use the /System option, in which
case the volume label will be sorted like a file record. Don't
put the volume label ahead of your boot files, if you want your
disk to be bootable.
Example: If you want to put the volume label "BIG DRIVE" just
after IO.SYS and MSDOS.SYS, set FORCED.LST to
IO.SYS
MSDOS.SYS
BIG DRIVE
and run
LFNSORT - c:\ /F forced.lst /System /D
Keeping original size:
Normally when LFNSORT sorts a directory, it removes erased file
entries, and shrinks the disk allocation for the directory as
much as possible. If you use the /K option, erased file entries
will moved to the end of the directory (but will not otherwise
be sorted), and the disk allocation of the subdirectory will be
left unchanged.
Exact sort rules:
What LFNSORT does when sorting a directory is to compare all
files, applying the following rules in order until it can tell
which of a pair of files should come first:
1. "." and ".." are always left in place.
2. If the /K option is used, then erased file entries are put
last in the directory, in their original order. With no
/K, the erased file entries will be deleted.
3. Unless you override it with the /System option, files
in the root directory with the System attribute will be
moved ahead of other files but will otherwise not be sorted.
The volume label entry will be moved just after them.
4. If you haven't used the /D option, then subdirectories
are placed before files.
5. If you have used a /F file to force a sort order, and the
current directory is listed there, then it is used to
specify the order. If the current directory isn't listed
there but files are listed with no directory name, then
that order is used. Any file which isn't listed is put in
the place of "*" in the list, which defaults to last.
6. The comparison rules given by the sort key are applied
in order from left to right.
7. If after all those comparisons LFNSORT can't tell which of
two files should come first, then they're left in the
original order (i.e. LFNSORT performs a "stable" sort.)
Running in DOS or DOS mode:
LFNSORT should be able to run in pre-Win95 versions of DOS, or
in the DOS mode of Win95 (the one you get if you "Restart
computer in MS-DOS mode" or choose console mode from the initial
boot menu). The main limitation is that long filenames aren't
supported on the command line or in the forced order file.
However, the (invisible) long filename records will still be
sorted, and the /V option can be used to print the long names of
files. Directory names will be printed in the 8.3 form.
Erased file records:
By default, LFNSORT deletes any erased file records that are
left in the directory. This helps to speed up disk access, but
it means that some file undeletion programs (the ones that don't
keep their own records of deleted files) won't be able to
undelete files after a LFNSORT run. LFNSORT will also by
default shrink the disk space used by a directory. Use the /K
option to keep erased files and to suppress shrinking of the
directory.
When both the /K "keep" and /V "verbose" options are used,
erased file entries will be printed with the first letter of the
short name changed to σ (ASCII 229), just as they are stored on
the disk. Erased long filenames will not be printed.
Errors on your disk:
When you run pre-Win95 versions of DOS and work with directories
containing long filenames, it is very easy to mess them up.
Some of these errors may cause LFNSORT to act in unpredictable
ways. I recommend always running SCANDISK after working with
files in DOS mode.
LFNSORT will detect the most common type of these errors,
"orphaned long filename records". These occur when you rename a
file in an old DOS, and the LFN part of the record isn't updated
properly, or when you delete a file in old DOS and the LFN
doesn't get deleted. If it finds these orphans, it will print a
warning message, and give you the option of continuing. If you
choose to continue, the orphaned records will be deleted.
Don't do this if you'd like to use some other program to recover
them; after LFNSORT sorts the directory, they'll be gone
forever.
4. Memory Limitations:
Once it has exclusive access to the disk, LFNSORT reads entire
subdirectories into memory all at once. Because this version is
a DOS real mode program, that limits the size of directory that
it can sort. It needs enough space to store two copies of the
whole directory record in memory, which means it will refuse to
sort directories with more than about 6000 short filenames.
Long filenames take up more space, and the limit will be lower.
If you have a directory that is too large to sort, LFNSORT will
just leave it as is on the disk. Your only choice then is to
manually move enough files out of the directory so that LFNSORT
can run, and then move the files back afterwards.
5. Safety:
LFNSORT works with your disk at a level below the file system,
so if things go wrong while rewriting a directory, it's
conceivable that you could lose whole files or directories.
I've tried to make it as safe as I can, but you should follow
some simple precautions:
- If you aren't sure of the integrity of your file system, run
Scandisk before LFNSORT and get it to fix any errors. In
particular, if you've run other low level software (e.g. a
defragger or DOS-based directory sorter) that may have messed
up the LFNs, run Scandisk first.
- Don't turn off or reboot your PC in the middle of an LFNSORT
run. If there's a power failure or (horrors!) a bug in
LFNSORT forces you to reboot, then Scandisk should be able to
repair most of the damage, but you may have to manually rename
some files.
- If you hit Ctrl-Break or Ctrl-C during an LFNSORT run,
it shouldn't do any damage other than giving you only a
partial sort.
- LFNSORT was written for version 4.00.950 of Windows 95 (the
August 1995 release). It hasn't been tested on the earlier
beta test versions or on any later release than the 4.00.950a
maintenance fix pack. If the VFAT file structure isn't what
LFNSORT is written for, it could do some real damage.
In particular, LFNSORT will definitely not work on FAT32, and
if everything works, it will refuse to run there --- but this
has never been tested since at the time of this writing FAT32
is still in beta testing.
- There may be special conditions on your system that LFNSORT
won't be able to handle. If you can, try it out first when
you've got a good backup to make sure it works. If it
doesn't, *please* send me details, and I'll attempt to fix it.
6. License:
LFNSORT is shareware, *not* public domain software. You may use
it at no charge for an evaluation period of 30 days only.
You are free to distribute unmodified copies of the complete
LFNSORT package, provided your total charge is no more than $1.
The total cost of a compilation (e.g. a CD ROM) including
LFNSORT must be no more than $1 per package in the compilation.
To continue to use LFNSORT beyond the 30 day evaluation period,
you must register it. There are three possible registration
levels available:
$10 simple registration + $5 handling charge
This registration fee gives you a license to use one copy of
LFNSORT indefinitely. If you include an email address I will
notify you of new versions and how to obtain them yourself. I'll
also attempt to answer emailed questions about LFNSORT from
registered users. Payment may be made in Canadian or US dollars
(at par), or the UKP equivalent of $15 US. NOTE: See below for
how to avoid the handling charge.
$20 upgrade registration + $5 handling charge
This registration fee also entitles you to use LFNSORT
indefinitely. In addition to the license to use it, I will mail
you a diskette containing the latest version, together with a
collection of other freeware and (unregistered) shareware
programs that I have written (including DOSLFNBK). If you send
an email address I will notify you of updates, and send one free
update by email if you request it. Payment may be made in
Canadian or US dollars (at par), or the GBP (Sterling)
equivalent of $25 US.
$45 source code registration + $5 handling charge
LFNSORT was written in Borland Pascal 7.01, using the excellent
Object Professional library from TurboPower Software. In
addition to the benefits of the upgrade registration, the source
code registration gives you the LFNSORT source code (including
an object-oriented low-level disk access unit, access to the new
Win95 DOS API functions, and a huge memory support unit, but not
OPro). Payment may be made in Canadian or US dollars (at par),
or the GBP equivalent of $50 US.
Any of the registrations can be done by sending a cheque or
money order to:
Duncan Murdoch
337 Willingdon Ave.
Kingston, Ontario, Canada.
K7L 4J3
NOTE 1: If you send a $10 simple registration order directly to
me at this address, I will waive the handling fee. Send a
cheque or money order for $10 in Canadian or US dollars, or the
UKP equivalent of $10 US.
NOTE 2: I will be going overseas from August 1996 to June 1997.
During this time I will still fill orders, but there are almost
certain to be delays.
You can also register or order source code from the Public
(software) Library (PsL) using MC, Visa, AmEx, or Discover card:
- by calling 800-242-4775 (US only)
- by calling 713-524-6394
- by faxing your order to 713-524-6398
- by sending your order by Compuserve to 71355,470
- by sending your order by Internet to
71355.470@compuserve.com
PsL only accepts payment in US dollars. Please give PsL your
name exactly as it appears on the card, and tell them your
card's expiry date. LFNSORT is PsL product #14528.
The PsL numbers are for ordering only. I *cannot* be reached at
the PsL numbers. To contact me for information about dealer
pricing, volume discounts, site licensing, the status of
shipment of the product, the latest version number or for
technical information, write to me at the address above or the
email address below. I'd especially like to hear bug reports
and suggestions for improvements.
Internet: dmurdoch@mast.queensu.ca
7. Release history:
0.0 - first alpha test version
0.1 - second test version. Bugs fixed; parameter parsing logic
rationalized; /NW and /V options added; DOS support added
0.2 - fixed bug with writing to a directory being sorted,
formatting /V
0.3 - worked around Stacker incompatibility
1.0 - first public release, same as 0.3 except for removal of
debugging code
1.1 - added special handling of volume labels
1.2 - dropped use of obsolete DOS service 1Ch,
minor cosmetic changes, improved memory management,
allowed use of SUBST, added check for existence of initial
directory, stopped treating System directories as special,
fixed display of volume label
1.3 - fixed bug which messed up disk if volume label matched
directory name; made it a tiny bit faster, and slightly
less vulnerable to errors on the disk; added /K option to
keep erased entries; added default shrinking of disk
allocation.
1.4 - Fixed minor empty root dir bug, /k bug, added integrity
check of directory before sorting
8. Known bugs
When run in Win95 in a DOS window, the window sometimes switches
to full screen when LFNSORT locks a disk drive. On some
systems, this results in junk on the screen.
Very large directories won't be sorted.
International character sets aren't sorted properly.
9. Acknowledgments
LFNSORT wouldn't have been written without the enthusiastic
encouragement of Jacques Bensimon. It relies heavily on the
source code to DOSLFNBK, which was written based on the
information in Robert Hummel's article on Win95 long filenames
in the June/July 1995 issue of PC Techniques Magazine. Thanks
are also due to the DOSLFNBK and LFNSORT beta testers, several
of whom were put to considerable inconvenience.